package com.sqstudio.view
{
	import com.sqstudio.common.TipManager;
	import com.sqstudio.ui.WeatherMC;
	import com.sqstudio.ui.WeatherTip;
	
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	
	public class WeatherPanel extends Sprite
	{
		
		private var weatherMc:WeatherMC;
		private var wtip:WeatherTip;
		public function WeatherPanel()
		{
			this.weatherMc = new WeatherMC();
			addChild(this.weatherMc);
			setTxtAtt([weatherMc.address_txt,weatherMc.today_txt,weatherMc.toma_txt,weatherMc.time_txt]);
			
			wtip = new WeatherTip();
			addChild(wtip);
			new TipManager(this.weatherMc.tip,wtip,-30);
			
			updateWeather("城市",["正在加载天气信息","正在加载天气信息","正在加载天气信息"]);
			updateTime("正在加载...");
		}
		
		private function setTxtAtt(txtArr:Array):void{
			for each(var txt:TextField in txtArr ){
				txt.mouseEnabled = txt.selectable = false;
			}
		}
		
		/**
		 *更新天气信息 
		 * @param $city
		 * @param $today
		 * @param $tomorrow
		 * 
		 */		
		public function updateWeather($city:String,$wDescArr:Array):void{
			this.weatherMc.address_txt.text = $city;
			this.weatherMc.today_txt.text =$wDescArr[0];
			this.weatherMc.toma_txt.text = $wDescArr[1];
			this.wtip.tip_txt.text = "后天:"+$wDescArr[2];
		}
		/**
		 *更新时间 
		 * @param $time
		 * 
		 */		
		public function updateTime($time:String):void{
			this.weatherMc.time_txt.text = $time;
		}
	}
}